package com.virus.coronavirus.config;

import com.alibaba.fastjson.JSON;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Bbeginner
 * @Date: 2021/2/26 13:24
 * @Version 1.0
 **/
@Configuration
@EnableSwagger2
public class SpringFoxConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.virus.coronavirus"))
                .paths(PathSelectors.any())
                .build();

    }

    /*private String getSwaggerData(){
        HttpURLConnection connection = null;
        String result = null;
        try {
            URL url = new URL("http://localhost:3/v2/api-docs");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.connect();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            connection.disconnect();
        }
        return result;
    }

    public class SwaggerBackendInfoBase {
        private String type;
        private String address;
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        public String getAddress() {
            return address;
        }
        public void setAddress(String address) {
            this.address = address;
        }
    }*/
}
